/*
 ============================================================================
 Name		: LlcpSendHandler.h
 Author	  : 
 Version	 : 1.0
 Copyright   : 
 Description : CLlcpSendHandler declaration
 ============================================================================
 */

#ifndef LLCPSENDHANDLER_H
#define LLCPSENDHANDLER_H

#include <e32base.h>	// For CActive, link against: euser.lib

class MLlcpConnOrientedTransporter;
class MP2PMessageSupplier;

class CLlcpSendHandler : public CActive
	{
public:
	// Cancel and destroy
	~CLlcpSendHandler();

	// Two-phased constructor.
	static CLlcpSendHandler* NewL(MLlcpConnOrientedTransporter* aTransporter,
			MP2PMessageSupplier* aMessageSupplier);
	

	// Two-phased constructor.
	static CLlcpSendHandler* NewLC(MLlcpConnOrientedTransporter* aTransporter,
			MP2PMessageSupplier* aMessageSupplier);

public:
	// New functions
	// Function for making the initial request
	void SendMessageL(const TDesC8& aMessage);

	void SendNextMessage();

private:
	// C++ constructor
	CLlcpSendHandler(MLlcpConnOrientedTransporter* aTransporter,
			MP2PMessageSupplier* aMessageSupplier);

	// Second-phase constructor
	void ConstructL();

private:
	// From CActive
	// Handle completion
	void RunL();

	// How to cancel me
	void DoCancel();

	// Override to handle leaves from RunL(). Default implementation causes
	// the active scheduler to panic.
	TInt RunError(TInt aError);
	
private:
	enum TLlcpSendHandlerState
		{
		EIdle,
		EConnecting,
		ETransmitting,
		EError
		// Error condition
		};

private:
	TInt iState; // State of the active object
	MLlcpConnOrientedTransporter* iTransporter;
	MP2PMessageSupplier* iMessageSupplier;
	RBuf8 iMessage;
	};

#endif // LLCPSENDHANDLER_H
